#include <stdio.h>

/**
 * 本例探索多维数组的存储方式和访问方式
*/

#define X 2
#define Y 3
#define Z 4

int main(void)
{
    int arr[X][Y][Z] = {
        {
            {1, 2, 3, 4},
            {5, 6, 7, 8},
            {9, 10, 11, 12}
        },
        {
            {11, 12, 13, 14},
            {15, 16, 17, 18},
            {19, 110, 111, 112}
        }
    };

    int *p = &arr[0][0][0];
    for (int i = 0; i < X * Y * Z; i++)
    {
        if (i > 0 && i % 4 == 0) {
            putchar('\n');
        }
        printf("%d\t", *(p + i));
    }
    putchar('\n');
    for (int i = 0; i < X; i++)
    {
        for (size_t j = 0; j < Y; j++)
        {
            for (size_t k = 0; k < Z; k++)
            {
                printf("arr[%d][%zu][%zu] = %d \t", i, j, k, arr[i][j][k]);
            }
            putchar('\n');
        }
        
    }
    
    return 0;
}